<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css">
    <script src="/static/layui/layui.js"></script>
    <script src="/static/jquery-latest.js"></script>
</head>
<body style="padding: 15px">
<form class="layui-form" action="">
    <input name="question-id" id="question-id" disabled style="display: none">
<div class="layui-card">
    <div class="layui-card-header">标题</div>
    <div class="layui-card-body layui-row layui-col-space10">
        <div class="layui-col-md12">
            <input id="question-title" type="text" name="title" lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">
        </div>
    </div>
</div>
<div class="layui-card">
  <div class="layui-card-header">测试描述</div>
  <div class="layui-card-body layui-row layui-col-space10">
    <div class="layui-col-md12">
      <textarea id="question-context" name="context" placeholder="请输入" lay-verify="required" class="layui-textarea" style="height: 440px"></textarea>
    </div>
  </div>
</div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="submit-button">编辑</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script>
    layui.use("form",function (){
        var form = layui.form;
        form.on('submit(submit-button)',function (data){
            $.ajax({
                url:'/teacher/Paper/edit',
                method:'put',
                data:data.field,
                dataType:'JSON',
                success:function(res){
                    if(res.code=='0'){
                        layer.msg("提交成功",{icon: 1, time: 1000},function(){
                            window.parent.location.href=("/teacher/Paper/edit/"+$("#question-id").val());
                            // var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            // parent.layer.close(index); //再执行关闭
                        }); //提交成功后刷新页面
                    }
                    else
                        window.location.replace("/404?msg="+res.msg);
                },
                error:function (data) {
                    window.location.replace("/404?msg="+data);
                }
            });
            return false;
        })
    })
</script>
</body>
</html>